package com.example.shiro.utils;

import java.util.Random;

public class SaltUtils {

    /**
     * 生成 salt 的静态方法
     * @return
     */
    public static String getSalt(int n){
        char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYzabcdefghijklmnopqrstuvwxyz0123456789".toCharArray();
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < n; i++) {
            char aChar = chars[new Random().nextInt(chars.length)];
            stringBuffer.append(aChar);
        }
        return stringBuffer.toString();
    }

}
